JQuery

Bootstrap modal popup example

Bootstrap modal popup example, someone asked me to explain?

In this article, I will show you JQuery bootstrap popup on button click with example. Initially popup was in hidden, when user clicks the show model popup, the jQuery event opens the bootstrap popup model. 

HTML code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>jQuery-bootstrap modal popup on button click</title>
    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript">
        $(function () {
            $("#btnShow").click(function () {
                $('#demoModal').modal('show');
            });
        });
    </script>
</head>
<body>
    <!--Buttonto Trigger Modal-->
    <div style="text-align: center; margin-top: 10%">
        <button id="btnShow" class="btn btn-primary btn-lg">Show Modal Popup</button>
    </div>
    <!--Modal -->
    <div class="modal fade" id="demoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Bootstrap Modal Popup</h4>
                </div>
                <div class="modal-body">content goes here..</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btnbtn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

 

Description:

The model popup contains title, body and footer section. You can give a title for the popup and also design form in the body section. The model close and save button is at the bottom of the bootstrap model popup.

Bootstrap  model popup Demo:

jquery bootstrap popup

 

Post your comments / questions